/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author bluepc
 */
@Entity
@Table(name = "Tables")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Tables.findAll", query = "SELECT t FROM Tables t"),
    @NamedQuery(name = "Tables.findByIdTable", query = "SELECT t FROM Tables t WHERE t.idTable = :idTable"),
    @NamedQuery(name = "Tables.findByTableStatus", query = "SELECT t FROM Tables t WHERE t.tableStatus = :tableStatus")})
public class Tables implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer idTable;
    @Basic(optional = false)
    @NotNull
    @Column(name = "table_status")
    private boolean tableStatus;
    @JoinColumn(name = "id_time", referencedColumnName = "id_time")
    @ManyToOne
    private TimeMeal idTime;
    @JoinColumn(name = "id_type", referencedColumnName = "id_type")
    @ManyToOne
    private Tabletype idType;
    @JoinColumn(name = "id_res", referencedColumnName = "id_res")
    @ManyToOne
    private Restaurant idRes;
    @OneToMany(mappedBy = "idTable")
    private List<BookTable> bookTableList;

    public Tables() {
    }

    public Tables(Integer idTable) {
        this.idTable = idTable;
    }

    public Tables(Integer idTable, boolean tableStatus) {
        this.idTable = idTable;
        this.tableStatus = tableStatus;
    }

    public Integer getIdTable() {
        return idTable;
    }

    public void setIdTable(Integer idTable) {
        this.idTable = idTable;
    }

    public boolean getTableStatus() {
        return tableStatus;
    }

    public void setTableStatus(boolean tableStatus) {
        this.tableStatus = tableStatus;
    }

    public TimeMeal getIdTime() {
        return idTime;
    }

    public void setIdTime(TimeMeal idTime) {
        this.idTime = idTime;
    }

    public Tabletype getIdType() {
        return idType;
    }

    public void setIdType(Tabletype idType) {
        this.idType = idType;
    }

    public Restaurant getIdRes() {
        return idRes;
    }

    public void setIdRes(Restaurant idRes) {
        this.idRes = idRes;
    }

    @XmlTransient
    public List<BookTable> getBookTableList() {
        return bookTableList;
    }

    public void setBookTableList(List<BookTable> bookTableList) {
        this.bookTableList = bookTableList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idTable != null ? idTable.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Tables)) {
            return false;
        }
        Tables other = (Tables) object;
        if ((this.idTable == null && other.idTable != null) || (this.idTable != null && !this.idTable.equals(other.idTable))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Tables[ idTable=" + idTable + " ]";
    }
    
}
